<?php
class TestController extends Controller {
	/**
	 * 测试使用curl模拟POST二进制流数据请求方式
	 */
	function actionTestPostImage() {
		$file = empty ( $_GET ['img'] ) ? 'http://c1.56img.com/huodong/14/12/index_support_20130523090450_97713.jpg' : $_GET ['img'];
		$data = file_get_contents ( $file, 'r' );
		// file_put_contents ( 'abc.jpg', $data );
		
// 		$url = 'http://www.sitestar.com:8787/test/testpostimagepostback';
$data = gzcompress($data);
$url = 'http://huodong.56.com:81/2012/imgadmin/index.php?action=ImgUpload&do=Process&returnway=2&appid='.urlencode('http://huodong.56.com/2012/test/').'&starttime=1369310885&token=d35de941e7477d3970e91c6c2f4a9e1f';
		$ch = curl_init ();
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE );
		curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
		curl_setopt ( $ch, CURLOPT_POST, TRUE );
		curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
		curl_setopt ( $ch, CURLOPT_URL, $url );
		curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 3 );
		
		$ret = curl_exec ( $ch );
		curl_close ( $ch );
		
		//header ( 'Content-Type: image/jpeg' );
		echo $ret;
	}
	/**
	 * actionTestPostImage 的回调函数
	 */
	public function actionTestPostImagePostback() {
		$str = file_get_contents ( 'php://input' );
		// $str = file_get_contents ( 'abc.jpg' );
		echo $str;
	}
	
	public function actionTestImagesize(){
		var_dump('http://c1.56img.com/huodong/26/18/3g_20130522175528_55421.jpg',getimagesize('http://c1.56img.com/huodong/26/18/3g_20130522175528_55421.jpg'));
		
		var_dump('http://c1.56img.com/huodong/26/18/3g_20130520115413_66950.jpg',getimagesize('http://c1.56img.com/huodong/26/18/3g_20130520115413_66950.jpg'));
	}
}